<?php
/**
 * User: YL
 * Date: 2019/6/11
 */

namespace restful\traits;

trait InstanceTrait
{
    protected static $instances = [];

    /**
     * getInstance
     * @param mixed ...$params
     * @return static
     */
    public static function getInstance(...$params)
    {
        $name = get_called_class();

        if (empty(static::$instances[$name])) {
            static::$instances[$name] = new static(...$params);
        }

        return static::$instances[$name];
    }
}